#include<bits/stdc++.h>
#define int long long
#define endl "\n"

using namespace std;

signed main() {
	int t;
	cin >> t;
	while(t -- ) {
		int n;
		cin >> n;
		if(n == 3) {
			int a[10];
			cin >> a[1] >> a[2] >> a[3];
			sort(a + 1, a + 3 + 1);
			if(a[1] + a[2] > a[3]) {
				cout << a[1] + a[2] + a[3] << endl;
			} else {
				cout << 0 << endl;
			}
			
			continue;
		}
		int sum = 0;
		for(int i = 1; i <= n; i ++ ) {
			int x;
			cin >> x;
			sum += x;
		}
		cout << sum << endl;
	}
	return 0;
}

